(function(){

  importScripts('pngquant.min.js');

  onmessage = function (event) {
    let e = event.data
    let speed = '4'
    if(e.data.byteLength/1024 >= 1024){
      speed = '10'
    }
    let result = pngquant(e.data,{quality:e.quality,speed},()=>{})
    postMessage({result,name:e.name})
  }

})();